<h1>View / Edit Survey '<?php echo $form->getObject()->getName()?>'</h1>
<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>
  <table>
    <tbody>
      <tr>
        <th><b>Name:&nbsp;</b></th>
        <td><b><?php echo $survey->getName() ?></b></td>
      </tr>
      <tr>
        <th><b>Description:&nbsp;</b></th>
        <td><b><?php echo $survey->getDescription() ?></b></td>
      </tr>
      <tr>
        <th><b>Status:&nbsp;</b></th>
        <td><b><?php echo $survey->getStatus() ?></b></td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <td colspan="2">
          &nbsp;<?php echo link_to('Edit', 'survey/edit?id='.$survey->getid()) ?>
          &nbsp;<?php echo link_to('Delete', 'survey/delete?id='.$survey->getid(),array('method' => 'delete', 'confirm' => 'Delete survey "'.$survey->getName().'" - Are you sure?')) ?>
          <br>
          Set Status: 
          &nbsp;<?php echo link_to('Under construction', 'survey/setstatus?id='.$survey->getid().'&status="Under-construction"') ?>
          &nbsp;<?php echo link_to('On-going', 'survey/setstatus?id='.$survey->getid().'&status=On-going') ?>
          &nbsp;<?php echo link_to('Closed', 'survey/setstatus?id='.$survey->getid().'&status=Closed') ?>
        </td>
      </tr>
    </tfoot>
  </table>

<br>
<br>

<!--form for adding questions-->
<form action="<?php echo url_for('question/create') ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
  <input type="hidden" name="question[survey_id]" id="question_survey_id" value="<?php echo $form->getObject()->getId()?>" />
    <?php echo $itemform->renderHiddenFields() ?>
  <table>
     <tr>
       <th>Question</th>
       <th>  </th>
       <th><?php echo $itemform['type']->renderLabel() ?></th>
       <th>  </th>
     </tr>
     <tr>
       <td><?php echo $itemform['content']->renderError() ?></td>
       <td>  </td>
       <td><?php echo $itemform['type']->renderError() ?></td>
       <td>  </td>
     </tr>
     <tr>
       <td><?php echo $itemform['content'] ?></td>
       <td>  </td>
       <td><?php echo $itemform['type'] ?></td>
       <td>  </td>
        <td><input type="submit" value="Add Item" /></td>
      </tr>
  </table>
</form>

<!--show existing questions-->

<br>
<br>
  <table>
    <tbody>
      <tr>
        <th>Question</th>
        <th> | </th>
        <th>Type</th>
        <th> | </th>
        <th>Edit</th>
        <th> | </th>
        <th>Delete</th>
      </tr>
      <?php foreach($form->getObject()->getQuestions() as $item){ ?>
      <tr>
        <td><?php echo $item->getContent() ?></td>
        <td> | </td>
        <td><?php echo $item->getType() ?></td>
        <td> | </td>
        <td><?php echo link_to('Edit', 'question/edit?id='.$item['id']) ?></td>
        <td> | </td>
        <td><?php echo link_to('Delete', 'question/delete?id='.$item['id'], array('method' => 'delete', 'confirm' => 'Are you sure?')) ?></td>
      </tr>
      <?php } ?>
    </tbody>
  </table>





